如果你要做自動更新程式,總要先學會下載吧
方法一
這並不需要用到物件 一個簡單的函數DoFileDownload即可做到 程式如下
Private Declare Function DoFileDownload Lib "shdocvw.dll" _
(ByVal lpszFile As String) As Long
Private Sub Command1_Click()
Dim sFileUrl As String
sFileUrl = StrConv("http://www.hosp.ncku.edu.tw/~cww/index.html", vbUnicode)
DoFileDownload sFileUrl
End Sub
方法二
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
Dim lReturn As Long
lReturn = URLDownloadToFile(0, "http://www.hosp.ncku.edu.tw/~cww/index.htm", "C:\index.html", 0, 0)
If lReturn = 0 Then
MsgBox "Download Complete.", vbInformation + vbOKOnly
End If
End Sub